import javax.microedition.midlet.MIDlet;

import com.sun.lwuit.Button;
import com.sun.lwuit.Container;
import com.sun.lwuit.Form;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.layouts.BoxLayout;



public class MainMenuForm extends Form implements ActionListener{

	Button start_chat;
	Button about;
	Button help;
	Button exit;
	httprequest midlet;
	
	public MainMenuForm(MIDlet midlet)
	{
		super("Main Menu");
		this.midlet=(httprequest)midlet;
		start_chat=new Button("Start Chat");
		about=new Button("About");
		help=new Button("Help");
		exit=new Button("Exit");
		
		this.setLayout(new BorderLayout());
		Container cnt=new Container(new BoxLayout(BoxLayout.Y_AXIS));
		start_chat.addActionListener(this);
		about.addActionListener(this);
		help.addActionListener(this);
		exit.addActionListener(this);
		cnt.addComponent(start_chat);
		cnt.addComponent(about);
		cnt.addComponent(help);
		cnt.addComponent(exit);
//		this.addComponent(BorderLayout.CENTER, start_chat);
//		this.addComponent(BorderLayout.CENTER, about);
//		this.addComponent(BorderLayout.CENTER, help);
//		this.addComponent(BorderLayout.CENTER, exit);
		
		this.addComponent(BorderLayout.CENTER, cnt);
		this.addCommandListener(this);
	}
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		Button but=(Button)arg0.getComponent();
		if(but==start_chat)
		{
			//System.out.println("Get action");			
			midlet.f.show();
		}
		else if(but==help)
		{
			midlet.help_screen.show();
		}
		else if(but==about)
		{
			midlet.about_screen.show();
		}
		else if(but==exit)
		{
			midlet.notifyDestroyed();
		}
	}

}
